<!DOCTYPE html>
<html>
<head>
    <title>药品查询--中软高科-2015</title>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="../Css/bootstrap.css"/>
    <link rel="stylesheet" type="text/css" href="../Css/bootstrap-responsive.css"/>
    <link rel="stylesheet" type="text/css" href="../Css/style.css"/>
    <script type="text/javascript" src="../Js/jquery.js"></script>
    <script type="text/javascript" src="../Js/jquery.sorted.js"></script>
    <script type="text/javascript" src="../Js/bootstrap.js"></script>
    <script type="text/javascript" src="../Js/ckform.js"></script>
    <script type="text/javascript" src="../Js/common.js"></script>
    <style type="text/css">
        body {
            padding-bottom: 40px;
        }

        .sidebar-nav {
            padding: 9px 0;
        }

        @media (max-width: 980px) {
            /* Enable use of floated navbar text */
            .navbar-text.pull-right {
                float: none;
                padding-left: 5px;
                padding-right: 5px;
            }
        }


    </style>
</head>
<body>

<form id="myForm" name="drugs" action="index.html" class="definewidth m20">
<table class="table table-bordered table-hover definewidth m10">
    <thead>
    <tr>
        <th>药品编号</th>
        <th>药品图片</th>
        <th>进价</th>
        <th>售价</th>
        <th>药品名称</th>
        <th>简单描述</th>
        <th>药品类型</th>
        <th>保质期</th>
        <th>详细描述</th>
        <th>供应商</th>
        <th>服用说明</th>
        <th>备注</th>
        <th>总进数量</th>
        <th>发药数量</th>
        <th>库存</th>
        <th>状态</th>
    </tr>
    </thead>
    <tbody id="tbody">
    </tbody>
    <tr>
        <td colspan="15">
            <button type="button" class="btn btn-success" onclick="exportInfo()">导出</button>
            导出文件位置:
            <input type="text" id="outStream" name="outStream" value="C:\Users\Administrator\Downloads">
            <button type="button" class="btn btn-success" onclick="black()">返回列表</button>
        </td>
    </tr>
</table>
</form>
<script type="text/javascript">
    loadData();

    function loadData() {
        $.ajax({
            type:"GET",
            url:"/drug/excelList",
            success: function(vo){
                let list = vo.list;
                let str="";
                for (let i = 0; i < list.length; i++)  {
                    let obj = list[i];
                    let id = obj.id;
                    let img = obj.img;
                    let inPrice = obj.inPrice;
                    let outPrice = obj.outPrice;
                    let drugName = obj.drugName;
                    let drugType = obj.drugType==null?'':obj.drugType;
                    let description = obj.description==null?'':obj.description;
                    let quality = obj.quality;
                    let detailDescription = obj.detailDescription;
                    let factory = obj.factory;
                    let instruction = obj.instruction;
                    let note = obj.note;
                    let totalNumber = obj.totalNumber;
                    let sentNumber = obj.sentNumber;
                    let resetNumber = obj.resetNumber;
                    let status = obj.status===0?'销售中':'售完';
                    str+='<tr>\n' +
                        '            <td style="vertical-align:middle;">'+id+'</td>\n' +
                        '            <td style="vertical-align:middle;">'+img+'</td>\n' +
                        '            <td style="vertical-align:middle;">'+inPrice+'</td>\n' +
                        '            <td style="vertical-align:middle;">'+outPrice+'</td>\n' +
                        '            <td style="vertical-align:middle;">'+drugName+'</td>\n' +
                        '            <td style="vertical-align:middle;">'+drugType+'</td>\n' +
                        '            <td style="vertical-align:middle;">'+description+'</td>\n' +
                        '            <td style="vertical-align:middle;">'+quality+'</td>\n' +
                        '            <td style="vertical-align:middle;">'+detailDescription+'</td>\n' +
                        '            <td style="vertical-align:middle;">'+factory+'</td>\n' +
                        '            <td style="vertical-align:middle;">'+instruction+'</td>\n' +
                        '            <td style="vertical-align:middle;">'+note+'</td>\n' +
                        '            <td style="vertical-align:middle;">'+totalNumber+'</td>\n' +
                        '            <td style="vertical-align:middle;">'+sentNumber+'</td>\n' +
                        '            <td style="vertical-align:middle;">'+resetNumber+'</td>\n' +
                        '            <td style="vertical-align:middle;">'+status+'</td>\n' +
                        '        </tr>'
                }
                $("#tbody").html(str);
                //填充分页数据
                fillPageData(vo.pageInfo);
            }
        });
    }

    function black() {
        window.location.href="/Medicine/index.html";
    }

    function exportInfo(){
        var outStream = $("#outStream").val();
        if(outStream == ""){
            alert("保存路径为空");
            return false;
        }
        $.ajax({
            type: "POST",
            data: "outStream="+outStream,
            dataType:"json",
            url: "/drug/excelInfo",
            success: function (vo) {
                alert(vo.msg)
                if(vo.code==200){
                    black();
                }
            }
        })
    }
</script>
</body>
</html>
